import request from '@/utils/request'
import type { TradeMarkResponse, Trademark } from './type'

enum API {
  TRADEMARK_URL = '/admin/product/baseTrademark/',
  ADDTRADEMARK_URL = '/admin/product/baseTrademark/save',
  UPDATETRADEMARK_URL = '/admin/product/baseTrademark/update',
  DELETETRADEMARK_URL = '/admin/product/baseTrademark/remove',
}

export const reqTrademarkList = (pageNo: number, limit: number) =>
  request.get<any, TradeMarkResponse>(`${API.TRADEMARK_URL}${pageNo}/${limit}`)

export const reqDeleteTradeMark = (id: number) => {
  return request.delete(`${API.DELETETRADEMARK_URL}/${id}`)
}

export const reqAddOrUpdateTrademark = (data: Trademark) => {
  if (data.id) {
    // 修改
    return request.put<any, any>(API.UPDATETRADEMARK_URL, data)
  } else {
    // 新增
    return request.post<any, any>(API.ADDTRADEMARK_URL, data)
  }
}
